package com.sgb.knowledgeshare.viewmodel;

import androidx.lifecycle.ViewModel;

import com.sgb.knowledgeshare.ShareConfig;
import com.sgb.knowledgeshare.entity.ShareUserInfoEntity;
import com.sgb.knowledgeshare.view.fragment.ShareVideoPlayUserFragment;
import com.swgk.core.base.api.ICallBack;
import com.swgk.core.base.model.entity.BaseEntity;
import com.swgk.core.util.MToast;
import java.util.HashMap;
import java.util.Map;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;

/**
 * Created by fq on 2020/9/11 0011
 * Description：
 */
public class ShareVideoPlayUserModel extends ViewModel {

    ShareVideoPlayUserFragment fragment;

    //    获取用户详情信息
    public void getUserHomePage( String userid) {
        Map map = new HashMap();
        map.put("userNo",userid );
        ShareConfig.getInstance().getApi().getUserHomePage(map).enqueue(new ICallBack<BaseEntity<ShareUserInfoEntity>>() {
            @Override
            public void onSuccess(BaseEntity<ShareUserInfoEntity> data) {
                if (data.getData() == null) {
                    return;
                }
                if (data.getState().equals(ShareConfig.RESPONSE_OK)) {
                    fragment.setUserData(data.getData());
                } else {
                    MToast.showToast(fragment.getActivity(), data.getMsg());
                }
            }
        });
    }

    //  关注和取消关注接口
    public void getFens(String userid) {
        Map map = new HashMap();
        map.put("userNo",userid );
        ShareConfig.getInstance().getApi().getfens(map).enqueue(new ICallBack<BaseEntity>() {
            @Override
            public void onSuccess(BaseEntity data) {
                if (data.getData() == null) {
                    return;
                }
                if (data.getState().equals(ShareConfig.RESPONSE_OK)) {
                    fragment.UpdataUserIfno();
                } else {
                    MToast.showToast(fragment.getActivity(), data.getMsg());
                }
            }
        });
    }

    public void setActivity(ShareVideoPlayUserFragment shareVideoPlayUserFragment) {
        fragment = shareVideoPlayUserFragment;
    }
}
